package Gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import PlayerManager.Player;
import PlayerManager.PlayerManager;
import GameFiles.GameManager;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class BirthdayPanel extends Frame {
	private static BirthdayPanel ref;
	private Dimension size;
	private Image img = new ImageIcon("Images\\birthdayImage.jpg").getImage();

	private BirthdayPanel() {
		setName("Happy Birthday!");
		Panel p = new Panel();
		p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5));
		this.add(p, "South");

		size = new Dimension(img.getWidth(null), img.getHeight(null));
		setSize(size);
		setMinimumSize(size);

		JButton ok = new JButton("OK");
		ok.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});

		add(ok, BorderLayout.SOUTH);
		this.pack();
		setVisible(true);
		collectMoney();
	}
	private void collectMoney(){
		int a_max=GameManager.getInstance().getNumberOfPlayers();
		Player curPlayer=new Player();
		int a_MoneyCollected=0;
		for(int i=0;i<a_max;i++){
			a_MoneyCollected+=100;
			curPlayer.RemoveCash(100);
			
			//subtract 100 from all players
		}		
		curPlayer.AddCash(a_MoneyCollected);
	}

	public void paintComponent(Graphics g) {
		int imgX = getSize().width / 2 - img.getWidth(this);
		int imgY = getSize().height / 2 - img.getHeight(this);
		g.drawImage(img, imgX, imgY, this);
	}

	public boolean Enter() {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean Execute() {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean Exit() {
		// TODO Auto-generated method stub
		return false;
	}

	public static BirthdayPanel getInstance() {
		if (ref == null)
			// it's ok, we can call this constructor
			ref = new BirthdayPanel();
		return ref;
	}
}
